<style>
    .hidden {
        display: none;
    }
</style>
<div class="layui-form" lay-filter="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">视频标题</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="videoTitle" value="{{ d.params.videoTitle || '' }}" lay-verify="videoTitle" autocomplete="off" class="layui-input">
            </script>
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">视频简介</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="videoPreview" value="{{ d.params.videoPreview || '' }}" lay-verify="videoPreview" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">视频链接</label>
            <div class="layui-input-inline">
                <script type="text/html" template>
                    <input type="text" name="videoUrl" value="{{ d.params.videoUrl || '' }}" autocomplete="off" class="layui-input">
                </script>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-inline">
                <script type="text/html" template>
                    <input type="text" name="time" value="{{ d.params.time || '' }}" id="date" lay-verify="time" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </script>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">详情</label>
        <div class="layui-input-block">
            <textarea id="demo" style="display: none;" value="{{ d.params.videoDetail || '' }}"></textarea>
        </div>
    </div>

    <script type="text/html" template>
        <input name="videoId" value="{{ d.params.videoId || '' }}" class="hidden">
    </script>
    <div class="btn-five" style=" margin: 30px 0px 0px 110px;">
        <div class="layui-input-inline">
            <input type="button" id="okbtn" lay-submit lay-filter="LAY-user-front-submit" value="确认" class="layui-btn" style="margin-bottom: 30px;">
        </div>
    </div>
</div>

<script>
    layui.use('upload', function() {
        var $ = layui.jquery,
            setter = layui.setter,
            admin = layui.admin,
            upload = layui.upload;

        //获取子菜单
        getmenu()

        function getmenu() {
            //取值
            var arr = sessionStorage.getItem('categoryId');
            admin.req({
                url: setter.request.baseUrl + "/product/admin/menu",
                data: {
                    parentId: 3
                },
                type: "get",
                done: function(res) {
                    if (res.code == 0) {
                        var html = "",
                            html1 = "";
                        html1 = "<option value=''>请选择</option>"
                        for (let i = 0; i < res.list.length; i++) {
                            html += "<option value=" + res.list[i].menuId + ">" + res.list[i].menuName + "</option>"
                        }
                        $("select[name='categoryId']").empty().append(html1 + html)
                        if (arr != "") {
                            $("select[name='categoryId'] option[value=" + arr + "]").attr("selected", true)
                        }
                        layui.form.render('select')
                    }
                },
            });
        }
        //上传文件   
        upload.render({
            elem: '#test1',
            url: setter.request.baseUrl + '/upload/admin/file',
            exts: 'txt|docx',
            accept: 'file',
            done: function(res) {
                layer.msg(res.message);
                layui.$('#uploadDemoView1').removeClass('layui-hide').find('a').attr('href', res.data.src);
                $("input[name='useBook']").val(res.data.src)
            }
        });
        //上传图片
        upload.render({
            elem: '.test2',
            url: setter.request.baseUrl + '/upload/admin/file',
            exts: 'jpg|png|jpeg',
            done: function(res) {
                layer.msg('上传成功');
                layui.$('#uploadDemoView2').removeClass('layui-hide').find('img').attr('src', res.data.src);
                $("input[name='licence']").val(res.data.src)
            }
        });
        upload.render({
            elem: '.test3',
            url: setter.request.baseUrl + '/upload/admin/file',
            exts: 'jpg|png|jpeg',
            done: function(res) {
                layer.msg('上传成功');
                layui.$('#uploadDemoView3').removeClass('layui-hide').find('img').attr('src', res.data.src);
                $("input[name='registeNo']").val(res.data.src)
            }
        });
        upload.render({
            elem: '.test4',
            url: setter.request.baseUrl + '/upload/admin/file',
            exts: 'jpg|png|jpeg',
            done: function(res) {
                layer.msg('上传成功');
                layui.$('#uploadDemoView4').removeClass('layui-hide').find('img').attr('src', res.data.src);
                $("input[name='productImg']").val(res.data.src)
            }
        });

    });
</script>